﻿using System;
using System.Collections.Generic;
using System.Text;
using DotNetCore.CAP;
using Microsoft.Extensions.Configuration;

namespace Core.Module.CapSubsribeService
{
    public static class CapRabbitMqOptionsExtension
    {

        public static Action<RabbitMQOptions> GetOptions(IConfigurationRoot rootConfigs)
        {
            var rabbitconfig= rootConfigs.GetSection("RabbitMQ");
            RabbitMQOptions options = new RabbitMQOptions();
            return (options) =>{
                options.HostName = rabbitconfig["HostName"];
                options.Port = Convert.ToInt32(rabbitconfig["Port"]); 
                options.UserName = rabbitconfig["UserName"];
                options.Password = rabbitconfig["Password"];
                options.VirtualHost = rabbitconfig["VirtualHost"];
            };
        }
    }
}
